#include <iostream>
#include <memory>
#include <string>

using namespace std;


/*
\ brief:  状态抽象接口类
\ author: 清晨与猫鱼
*/
class State {
public:

/*
\ brief:  内部类 
\ author: 清晨与猫鱼
*/
    class Context {
    public:
        explicit Context() 
            : state_(nullptr) {
        }

        void setState(State* state) {
            state_ = state;
        }

        State* getState() {
            return state_;
        }
    private:
        State* state_;      // 状态类引用
    };

    virtual void doAction(Context& context) = 0;
    virtual string toString() = 0;
};


/*
\ brief:  开始状态
\ author: 清晨与猫鱼
*/
class StartState 
    : public State {
public:
    void doAction(Context& context) {
        cout << "Player is in start state" << endl;
        context.setState(this);     // 设置当前状态
    }

    string toString() {
        return "Start State";
    }
};


/*
\ brief:  停止状态
\ author: 清晨与猫鱼
*/
class StopState 
    : public State {
public:
    void doAction(Context& context) {
        cout << "Player is in stop state" << endl;
        context.setState(this);
    }

    string toString() {
        return "Stop State";
    }
};